<?php

class Quantri_NhomhanghoadvController extends Zend_Controller_Action
{

    public function init()
    {
        $option=array(
        		"layout" => "layout",
        		"layoutPath" => APPLICATION_PATH."/layouts/scripts/quantri"
        );
        Zend_Layout::startMvc($option);
        
        $this->view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
    }

    public function indexAction()
    {
    	$nhomhanghoadv = new Quantri_Model_Nhomhanghoadv();
    	$rsNhomhanghoadv = $nhomhanghoadv->GetAll();
    	
    	$this->view->rsNhomhanghoadv = $rsNhomhanghoadv->toArray();
    }
    public function saveAction()
    {
    	$this->_helper->layout()->disableLayout();
    	$this->_helper->viewRenderer->setNoRender(true);
    
    	$nhomhanghoadv = new Quantri_Model_Nhomhanghoadv();
    
    	$Id = $this->_request->getParam("idNhomhanghoadv","-1");
    	$ten = $this->_request->getParam("ten","");
    	$trangthai = $this->_request->getParam("trangthai","");
    
    	$nhomhanghoadv->Id=$Id;
    	$nhomhanghoadv->Ten = $ten;
    	$nhomhanghoadv->TrangThai = $trangthai;
    	$nhomhanghoadv->save();
    	
    }
    
    public function xoaAction()
    {
    	$this->_helper->layout()->disableLayout();
    	$this->_helper->viewRenderer->setNoRender(true);
    
    	$nhomhanghoadv = new Quantri_Model_Nhomhanghoadv();
    	$id = $this->_request->getParam("id", "-1");
    
    	$nhomhanghoadv->xoa($id);
    }
    
    public function suaAction()
    {
    	$this->_helper->layout()->disableLayout();
    	$this->_helper->viewRenderer->setNoRender(true);
    
    	$idNhomhanghoadv = $this->_request->getParam("id","-1");
    
    	$nhomhanghoadv = new Quantri_Model_Nhomhanghoadv();
    	$nhomhanghoadv->Id = $idNhomhanghoadv;
    
    	$rsNhomhanghoadv = $nhomhanghoadv->GetById();
    	
    	echo json_encode($rsNhomhanghoadv);
    }
}





